package com.hackcloud.shardingjdbc.service;

import com.hackcloud.shardingjdbc.domain.center.ApplyCenterMain;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.concurrent.ThreadPoolExecutor;

@Service
public class ApplyCenterServiceFactory implements ApplicationContextAware {
    @Autowired
    ThreadPoolExecutor poolExecutor;
    private static ApplicationContext applicationContext;

    public void execute(String json) {
        AbstractApplyCenterService applyCenterService = applicationContext.getBean("060401" + AbstractApplyCenterService.SERVICE_SUFFIX, AbstractApplyCenterService.class);
        applyCenterService.save(json);

    }

    public List<ApplyCenterMain> read() {
        AbstractApplyCenterService applyCenterService = applicationContext.getBean("060401" + AbstractApplyCenterService.SERVICE_SUFFIX, AbstractApplyCenterService.class);
        return applyCenterService.read();

    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        this.applicationContext = applicationContext;
    }
}
